import React, { Component } from 'react';
import axios from 'axios';
import Banner from './Banner';
import List from './List';
import Homekind from './Homekind';
import Homehot from './Homehot';
import store from '@/store';

class App extends Component {
	constructor (props) {
	  super(props);
		this.state = {
			imgHeight: 176
		}
	}
	componentDidMount () {
		axios.get('http://10.8.161.56:3000/users/banner')
		  .then((data) => {
				console.log('banner',data.data)
				store.dispatch({
					type: 'CHANGE_BANNER_LIST',
					data: data.data
				})
			})
		axios.get('http://10.8.161.56:3000/users/goodsgirl')
			.then((data) => {
				console.log('list',data.data)
				store.dispatch({
					type: 'CHANGE_PRO_LIST',
					data: data.data
				})
			})
  }
	goSearchPage () {
		this.props.history.push('/search')
	}
	goPageFn (id) {
		this.props.history.push('/detail/'+id);
	}
  render() {
    return (
      	<div className="box">
      		<header className="header">
						<div className="ssk">
							<i className="iconfont icon-icon-search"></i>
							<input type="text" className="ss" placeholder="时尚潮流风向看这里" onClick={ this.goSearchPage.bind(this) }/>
						</div>
					</header>
      		<div className="content">
      			<Banner bannerlist = { store.getState().home.bannerlist } imgHeight = { this.state.imgHeight } />
						<Homekind />
						<Homehot />
						<List prolist = { store.getState().home.list } goPageFn = { this.goPageFn.bind(this) }/>
      		</div>
      	</div>
    );
  }
}

export default App;
